//
//  WidgetVariable.m
//  WebClipper
//
//  Created by Daniel Braun on 26/04/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "WidgetVariable.h"
#import "MyDocument.h"
#import "WCExtractSetArray.h"

@implementation WidgetVariable

- (id) init {
	self = [super init];
	if (self != nil) {
	}
	return self;
}

- (void) dealloc {
	[name release];
	[super dealloc];
}


- (BOOL)ok
{
	MyDocument *md=[[NSDocumentController sharedDocumentController]currentDocument];
	if (!md) return NO;
	WCExtractSetArray *ea=[md _esets];
	NSAssert(ea, @"no esets in doc\n");
	NSArray *v=[ea allVariables];
	unsigned int i, count = [v count];
	for (i = 0; i < count; i++) {
		NSString * vn = [v objectAtIndex:i];
		if ([name isEqualToString:vn]) return YES;
	}
	return NO;
}

#if 0
- (void)setOk:(BOOL)value
{	
	ok = value;	
}
#endif


- (NSString *)name {
	return name;
}

- (void)setName:(NSString *)value {
	if (name != value) {
		[name release];
		name = [value retain];
	}
}


@end
